package com.zhenglide.controller;

import com.zhenglide.entity.Emp;
import com.zhenglide.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("emp")
@RestController
public class EmpController {
    @Autowired
    IEmpService empService;
    @GetMapping("list")
    public List<Emp> list(){
         return empService.list();
    }

    @PostMapping("add")
    public  Emp add (@RequestBody Emp emp){
        empService.save(emp);
          return emp;
    }
    @DeleteMapping("delete/{id}")
    public boolean delete(@PathVariable("id") Integer id){
        return  empService.removeById(id);
    }
    @PostMapping("modify")
    public  boolean modify (@RequestBody Emp emp){
        return  empService.updateById(emp);
    }
}
